using System;
using System.Collections.Generic;
using System.Globalization;

namespace com.adjust.sdk
{
	public class AdjustAttribution
	{
		public string adid { get; set; }

		public string network { get; set; }

		public string adgroup { get; set; }

		public string campaign { get; set; }

		public string creative { get; set; }

		public string clickLabel { get; set; }

		public string trackerName { get; set; }

		public string trackerToken { get; set; }

		public string costType { get; set; }

		public double? costAmount { get; set; }

		public string costCurrency { get; set; }

		public string fbInstallReferrer { get; set; }

		public AdjustAttribution()
		{
		}

		public AdjustAttribution(string jsonString)
		{
			JSONNode jSONNode = JSON.Parse(jsonString);
			if (!(jSONNode == null))
			{
				trackerName = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyTrackerName);
				trackerToken = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyTrackerToken);
				network = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyNetwork);
				campaign = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyCampaign);
				adgroup = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyAdgroup);
				creative = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyCreative);
				clickLabel = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyClickLabel);
				adid = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyAdid);
				costType = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyCostType);
				try
				{
					costAmount = double.Parse(AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyCostAmount), CultureInfo.InvariantCulture);
				}
				catch (Exception)
				{
				}
				costCurrency = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyCostCurrency);
				fbInstallReferrer = AdjustUtils.GetJsonString(jSONNode, AdjustUtils.KeyFbInstallReferrer);
			}
		}

		public AdjustAttribution(Dictionary<string, string> dicAttributionData)
		{
			if (dicAttributionData != null)
			{
				trackerName = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyTrackerName);
				trackerToken = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyTrackerToken);
				network = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyNetwork);
				campaign = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCampaign);
				adgroup = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyAdgroup);
				creative = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCreative);
				clickLabel = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyClickLabel);
				adid = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyAdid);
				costType = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCostType);
				try
				{
					costAmount = double.Parse(AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCostAmount), CultureInfo.InvariantCulture);
				}
				catch (Exception)
				{
				}
				costCurrency = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCostCurrency);
				fbInstallReferrer = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyFbInstallReferrer);
			}
		}
	}
}
